package com.hdu.hot100.backTrack;

import java.util.ArrayList;
import java.util.List;

public class lc17 {
    class Solution {
        String[] mappings = new String[]{
                "",
                "",
                "abc",
                "def",
                "ghi",
                "jkl",
                "mno",
                "pqrs",
                "tuv",
                "wxyz"
        };

        List<String> ans = new ArrayList<>();
        public List<String> letterCombinations(String digits) {
            if (digits.isEmpty())
            {
                return ans;
            }
            f(digits, 0, "");
            return ans;
        }

        void f(String digits, int index, String path)
        {
            if (index == digits.length())
            {
                ans.add(path);
                return;
            }
            int cur = digits.charAt(index) - '0';
            String curS = mappings[cur];
            for (int i = 0; i < curS.length(); i++)
            {
                f(digits, index + 1, path + curS.charAt(i));
            }
        }
    }
}
